package com.seaboxdata.jt809.common.util;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import redis.clients.jedis.params.SetParams;

/**
 * @author
 * @create 2021-04-23 15:43
 **/
public class RedisUtil {
    public static Jedis jedis;
    public static String expireTime = PropertiesUtil.getProperty("redis.string.expire");

    static {
        JedisPool pool = new JedisPool(new JedisPoolConfig(), PropertiesUtil.getProperty("redis.host"), Integer.valueOf(PropertiesUtil.getProperty("redis.port")), 65000, null, 4);
        jedis = pool.getResource();
    }

    public static void setString(String key, String value) {
        jedis.set(key, value, new SetParams().ex(Integer.valueOf(expireTime)));
    }

    public static String getString(String key) {
        return jedis.get(key);
    }
}
